package hc.bre.log

@Deprecated
@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true, includePackage = false)
class OutputTool {
	void error(Object ... args) {
		log('error',args)
	}
	void warn(Object ... args) {
		log('warn',args)
	}
	void info(Object ... args) {
		log('info',args)
	}

	private log(String type, Object ... args) {
		RuleLogger logger = RuleLogger.get()
		if(logger.rootRuleLog == null) {
			println "UserLogger is called without rule context. type:${type},messages:${args}"
			return;
		}

		OutputItem item = new OutputItem();
		item.logLevel = type;
		item.ruleClass = logger.ruleCalledStack.peek().ruleClass;
		item.content = args.length==1? args[0]:args;
		
		logger.rootRuleLog.outputs.add(item);
	}
}

